﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script src="~/plugins/mzui/js/mzui.min.js"></script>
    <link href="~/plugins/mzui/css/mzui.min.css" rel="stylesheet" />
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=ctYMfgeMnH3VDdzetRa1fed2FpclBS2T"></script>
    <title>@ViewBag.name</title>
    <style>
        .tiles .cell {
            flex: none;
        }
    </style>
</head>
<body class="with-nav-bottom">
    <div class="heading outline">
        <div class="title white"><strong>@ViewBag.name</strong></div>
    </div>
    <div class="list">
        <div class="item multi-lines white">
            <div class="content">
                <div><img src="@ViewBag.picture" onerror="this.src = '/images/nopic.png'" style="height:250px;width:100%;" /></div>
                <div class="row tiles" style="margin-top:0.1rem;">
                    @foreach (var item in @ViewBag.tese)
                    {
                        <div class="cell"><div class="label info outline">@item</div></div>
                    }
                </div>
                <div><label class="small text-gray">人均:@ViewBag.xfx-@ViewBag.xfd</label> <label class="label info rounded">@ViewBag.zhekou</label><label id="dz" class="btn has-badge pull-right" onclick="return dz(@Request.QueryString["uzan"],'@Request.QueryString["gid"]');"><i id="dzc" class="@(Request.QueryString["uzan"]=="0"?"icon-thumbs-o-up":"icon-thumbs-up")"></i> <span class="label info-pale">@Request.QueryString["zan"]</span></label></div>
            </div>
        </div>
    </div>
    <div class="divider"></div>
    <div class="item white" data-display data-backdrop="true" data-target="#map">
        <div class="heading">
            <div class="title"><strong><i class="icon-map-marker"></i></strong> <label id="addr">@ViewBag.address</label></div>
        </div>
    </div>
    <div class="divider"></div>
    <div class="section">
        <div class="heading">
            <div class="title"><strong>最惠待遇</strong></div>
        </div>
        <div class="divider"></div>
        <div class="box">
            @foreach (var item in @ViewBag.zk)
            {
                if (@item.mingzhe != 1.00M)
                {
                    <div class="cell">
                        <div class="label info outline">@item.name</div>
                        <div class="label gray">可享受</div>
                        <div class="label primary circle">@(item.mingzhe *10) 折</div>
                    </div>
                }
            }
        </div>
    </div>
    <div id="map" class="affix dock-bottom modal hidden">
        <div class="heading">
            <div class="title"><strong>商家地图</strong></div>
            <nav class="nav"><a data-dismiss="display"><i class="icon-remove muted"></i></a></nav>
        </div>
        <div id="allmap" style="width:100%;height:300px;"></div>
    </div>
    <div class="divider"></div>
    <div class="item white">
        <div class="heading">
            <div class="title"><strong><i class="icon-phone"></i></strong> <a href="tel:@ViewBag.lxfs">@ViewBag.lxfs</a></div>
        </div>
        <div class="divider"></div>
    </div>
    <div class="section">
        <div class="heading">
            <div class="title"><strong>商家介绍</strong></div>
        </div>
        <div class="divider"></div>
        <div class="box">
            @ViewBag.explain
        </div>
    </div>
    <div class="section">
        <div class="heading">
            <div class="title"><strong>商家详情</strong></div>
        </div>
        <div class="divider"></div>
        <div class="box">
            @Html.Raw(ViewBag.introduce)
        </div>
    </div>
    <div class="section">
        <div class="heading">
            <div class="title"><i class="icon icon-comments-alt muted"></i> <strong>消费评价</strong></div>
        </div>
        <div class="list comments" id="tbody">
            <script id="tpl" type="text/html">
                {{each list as item index}}
                <div class="item with-avatar multi-lines">
                    <a class="avatar circle" data-dark="true" data-skin="" style="background-color: rgb(81, 157, 224); border-color: rgb(81, 157, 224); color: rgb(255, 255, 255);">
                        {{if item.shoppj=="1"}}
                        优
                        {{else if item.shoppj=="2"}}
                        合格
                        {{else}}
                        差
                        {{/if}}
                    </a>
                    <div class="content">
                        <div>
                            <a class="text-link strong">{{item.nickname}}</a>
                            <div class="muted small pull-right">{{item.addtime}}</div>
                        </div>
                        <div class="btn-reply state">{{item.msg}}</div>
                    </div>
                </div>
                <div class="list {{item.tomsg == "等待回复" ?"hidden":""}}">
                    <div class="item with-avatar multi-lines">
                        <a class="avatar circle" data-dark="true" data-skin="" style="background-color: rgb(224, 103, 81); border-color: rgb(224, 103, 81); color: rgb(255, 255, 255);">
                            {{if item.userpj=="1"}}
                            优
                            {{else if item.userpj=="2"}}
                            合格
                            {{else}}
                            差
                            {{/if}}
                        </a>
                        <div class="content">
                            <div>
                                <small class="muted">商家回复</small>
                                <div class="muted small pull-right">{{item.pltime}}</div>
                            </div>
                            <div class="btn-reply state">{{item.tomsg}}</div>
                        </div>
                    </div>
                </div>
                {{/each}}
            </script>
        </div>
        <div class="divider"></div>
        <nav class="nav justified pager">
            <a class="pager-more" id="nextpage" onclick="getlist(document.getElementById('pageindex').innerHTML);"><span class="text-link">显示更多 <i class="icon icon-double-angle-down"></i></span></a>
        </nav>
    </div>
    <div id="buy" class="affix dock-bottom modal hidden">
        <div class="heading">
            <div class="title"><strong>在线买单</strong></div>
            <nav class="nav"><a data-dismiss="display"><i class="icon-remove muted"></i></a></nav>
        </div>
        <div class="divider"></div>
        <div class="section">
            <table class="table bordered">
                <tbody>
                    <tr>
                        <td>商家折扣</td>
                        <td>在线买单 @ViewBag.zhekou 折</td>
                    </tr>
                    <tr>
                        <td>输入原价</td>
                        <td>
                            <input name="yj" id="yj" type="text" style="width:50px;text-align:center;" onkeyup="value=value.replace(/[^\d]/g,'');" onchange="jsjg();">
                        </td>
                    </tr>
                    <tr>
                        <td>折扣后价格</td>
                        <td id="zkjg">请输入消费金额</td>
                    </tr>
                    <tr>
                        <td colspan="2" class="text-center"><button id="wx" type="button" class="btn primary" onclick="pay();">微信支付</button></td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <!-- 底部 -->
    <nav class="nav affix dock-bottom justified">
        <a onclick="history.go(-1);" class="active text-info">商城</a>
        <a href="/user/grzx">我的</a>
        <a class="btn primary hidden" data-display data-backdrop="true" data-target="#buy">在线买单</a>
    </nav>
    <label id="pageindex" class="hidden">0</label><label id="pages" class="hidden">1</label>
    <label id="Controllers" class="hidden">/home/pllist?cpgid=@Request.QueryString["gid"]</label>
    <script src="~/js/template-web.js"></script>
    <script src="~/js/mlist.js"></script>
    <script>
        function pay() {
            if (Number(document.getElementById("yj").value) >=10) {
                $.ajax({
                url: "/ajax/api.ashx",
                data: "ff=pay&shopgid=@Request.QueryString["gid"]&yj=" + document.getElementById("yj").value+"&Cache=" + Math.random(),
                type: "post",
                cache: false,
                timeout: 8000,
                dataType: "json",
                ContentType: "application/json; charset=utf-8",
                async: false,//一定要是同步请求，否则会跳转；（ajax默认是异步的）
                error: function () { document.getElementById("wx").innerText = "微信支付"; document.getElementById("wx").removeAttribute("disabled"); alert("AJAX Error"); },
                beforeSend: function () { document.getElementById("wx").innerText = "提交订单中..."; document.getElementById("wx").setAttribute("disabled", true); },
                success: function (data) {
                    document.getElementById("wx").innerText = "微信支付";
                    document.getElementById("wx").removeAttribute("disabled");
                    if (data.appId != "payerr") {
                        WeixinJSBridge.invoke('getBrandWCPayRequest', data, function (res) {
                            switch (res.err_msg) {
                                case "get_brand_wcpay_request:ok":
                                    self.location = "/home/msg?url=/user/wddd&msg=支付成功";
                                    break;
                                case "get_brand_wcpay_request:cancel":
                                    alert("你取消了支付,微信返回信息:" + res.err_msg);
                                    break;
                                default:
                                    alert("支付失败,微信返回信息:" + res.err_msg);
                                    break;
                            }
                        });
                    }
                    else
                    {
                        alert(data.return_msg);
                        if (data.return_msg == "请先升级会员") {
                            self.location = "/home/zcpay?lx=1";
                        }
                        else {
                            self.location = "/home/denglu?lx=1";
                        }
                    }
                },});
            }
            else
            {
                alert("支付金额必须不少于10元");
            }
        }
        //计算价格
        function jsjg()
        {
            //$("#zkjg").html(parseInt(Number(document.getElementById("yj").value * (Number(@ViewBag.zhekou) / 10))));
        }
        function dz(uzan, gid) {
            if (uzan == 0) {
                $.ajax({
                    url: "/home/dz",
                    data: gid,
                    type: "post",
                    cache: false,
                    timeout: 8000,
                    dataType: "json",
                    ContentType: "application/json; charset=utf-8",
                    error: function () { alert("请求超时"); },
                    beforeSend: function () { },
                    success: function (data) {
                        if (data.data.num == 1) {
                            $("#dz").removeAttr("onclick");
                            $("#dzc").removeClass("icon-thumbs-o-up").addClass("icon-thumbs-up");
                            $("#dz").children()[1].innerHTML = Number($("#dz").children()[1].innerHTML) + 1;
                        }
                    },
                });
            }
            return false;
        }
        // 百度地图API功能
        var map = new BMap.Map("allmap");
        var point = new BMap.Point(116.331398, 39.897445);
        map.centerAndZoom(point, 12);
        // 创建地址解析器实例
        var myGeo = new BMap.Geocoder();
        // 将地址解析结果显示在地图上,并调整地图视野
        myGeo.getPoint(document.getElementById("addr").innerHTML, function (point) {
            if (point) {
                map.centerAndZoom(point, 16);
                map.addOverlay(new BMap.Marker(point));
                map.panBy(305, 165);
                var opts = {
                    width: 200,     // 信息窗口宽度
                    height: 50,     // 信息窗口高度
                    title: document.getElementsByClassName("title")[0].innerHTML, // 信息窗口标题
                    enableMessage: true,//设置允许信息窗发送短息
                    message: "来这吧.优惠多多.老板在等你哦~"
                }
                var infoWindow = new BMap.InfoWindow(document.getElementById("addr").innerHTML, opts);  // 创建信息窗口对象
                map.openInfoWindow(infoWindow, point);
            }
        }, "福州市");
    </script>
</body>
</html>